package cn.liccshop.core.service.shopOrderReturn.service;

import cn.liccshop.core.entity.ShopOrderInfo;
import cn.liccshop.core.entity.ShopOrderReturn;
import cn.liccshop.core.service.shopOrderInfo.mapper.ShopOrderInfoMapper;
import cn.liccshop.core.service.shopOrderReturn.mapper.ShopOrderReturnMapper;
import cn.liccshop.core.service.shopOrderReturn.service.IShopOrderReturnService;
import cn.liccshop.sys.constants.Constants;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiCC
 * @since 2019-05-16
 */
@Service
public class ShopOrderReturnServiceImpl extends ServiceImpl<ShopOrderReturnMapper, ShopOrderReturn> implements IShopOrderReturnService {

    @Autowired
    private ShopOrderInfoMapper orderInfoMapper;

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void saveInfo(ShopOrderReturn orderReturn) {
        baseMapper.insert(orderReturn);
        orderInfoMapper.updateById(new ShopOrderInfo().setId(orderReturn.getOrderId()).setOrderStatus(Constants.ORDER_STATUS_APPLAY_RETURN).setApplayReturnTime(LocalDateTime.now()));
    }
}
